#pip install fastapi uvicorn

import uvicorn
from fastapi import FastAPI
import random


app = FastAPI()

#模拟抽奖接口, 中奖概率10%
@app.get("/")
def read_root():
    #产生一个0-1之间的随机数
    number = random.random()
    print("number=%f"%number)
    if number<=0.10:
        return {"code":0, "name":"抽奖成功"} #抽奖成功
    else:
        return {"code":1, "name":"抽奖失败"} #抽奖失败


if __name__ == '__main__':
    uvicorn.run(app, host="0.0.0.0")